<?php
class ent_image extends Lead_EDO_Object_Abstract
{
    static $_tables = array('ent_pic');
    
    public $picfile;
    public $picpath;
    public $picpath_file;
    public $picsize;
    
  	public $extension = array(2 => ".jpg", 3 => ".png");
	public $floats = array(NULL, "left", "right");
	public $borders = array(NULL, "border");
	
	public $output;

    
    public function __construct(Lead_EDO_Handler_Interface $handler)
    {
        parent::__construct($handler);
    }
    
    
    public function fetch($id)
    {
        parent::fetch($id);
        
        $app = Led_Application::getInstance();
        
        if($this->picid) {
            $this->picfile = $this->getHandler()->get('ent_imagefile')->fetch($this->picid);
            
            
            if($this->rendering) {
				// $this->ConfirmScaled();
				
				$this->output = 2;
												
				$this->picpath = $app->getRetailRoot() . "/data/3/" . $this->id . "_scaled" . $this->extension[$this->output];
				$this->picpath_file = $app->getExpoRoot() . "/data/3/" . $this->id . "_scaled" . $this->extension[$this->output];
				
				if(is_readable($this->picpath_file))
				    $this->picsize = getimagesize($this->picpath_file);
			} else {
							    			    
			    $this->picpath = $this->picfile->picpath;
				$this->picpath_file = $this->picfile->picpath_file;
				$this->picsize = $this->picfile->picsize;	
			}
            
        }
        
    }
    
    
}
?>